﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using SalePartial.Utility;
using System.Data;
using SalePartial.IDAL;
using SalePartial.Model;

namespace SalePartial.SQLServerDAL
{

//<DataObjectt(True)> _
    public class XPFavoriteVedor : IXPFavoriteVedor
{
	// Methods
	//<DataObjecttMethod(DataObjectMethodType.Delete)> _
	public int Delete(int FavorID)
	{
		int RowsAffected = 0;
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("FavorID", FavorID) };
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorDelete]", parameters, RowsAffected);
	}

	//<DataObjecttMethod(DataObjectMethodType.Delete)> _
	public int DeleteByCompanyID(Guid CompanyID)
	{
		int RowsAffected = 0;
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("CompanyID", CompanyID) };
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorsDeleteByCompanyID]", parameters, RowsAffected);
	}

	//<DataObjecttMethod(DataObjectMethodType.Delete)> _
	public int DeleteByVendorID(Guid VendorID)
	{
		int RowsAffected = 0;
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("VendorID", VendorID) };
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorsDeleteByVendorID]", parameters, RowsAffected);
	}

	//<DataObjecttMethod(DataObjectMethodType.Delete)> _
	public int DeleteDynamic(string v_whereCondition)
	{
		int RowsAffected = 0;
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("WhereCondition", v_whereCondition) };
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorsDeleteDynamic]", parameters, RowsAffected);
	}

	//<DataObjecttMethod(DataObjectMethodType.Insert)> _
	public int Insert(XPFavoriteVedorInfo info)
	{
		int RowsAffected = 0;
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] {
			new SqlParameter("FavorID", info.FavorID),
			new SqlParameter("CompanyID", info.CompanyID),
			new SqlParameter("VendorID", info.VendorID),
			new SqlParameter("FolderID", info.FolderID),
			new SqlParameter("CreateDate", info.CreateDate),
			new SqlParameter("LastSaveDate", info.LastSaveDate),
			new SqlParameter("DeleteDate", info.DeleteDate),
			new SqlParameter("Comment", info.Comment)
		};
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorInsert]", parameters, RowsAffected);
	}

	//<DataObjecttMethod(DataObjectMethodType.Select)> _
	public DataSet SelectAll()
	{
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[0];
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorsSelectAll]", parameters, "XPFavoriteVedor_All");
	}

	//<DataObjecttMethod(DataObjectMethodType.Select)> _
	public DataSet SelectByCompanyID(Guid CompanyID)
	{
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("CompanyID", CompanyID) };
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorsSelectByCompanyID]", parameters, "XPFavoriteVedor_ByCompanyID");
	}

	//<DataObjecttMethod(DataObjectMethodType.Select)> _
	public DataSet SelectByVendorID(Guid VendorID)
	{
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("VendorID", VendorID) };
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorsSelectByVendorID]", parameters, "XPFavoriteVedor_ByVendorID");
	}

	//<DataObjecttMethod(DataObjectMethodType.Fill)> _
	public DataSet SelectDynamic(string v_whereCondition, string v_orderByExpression)
	{
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] {
			new SqlParameter("WhereCondition", v_whereCondition),
			new SqlParameter("OrderByExpression", v_orderByExpression)
		};
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorsSelectDynamic]", parameters, "XPFavoriteVedor_Dynamic");
	}

	//<DataObjecttMethod(DataObjectMethodType.Fill)> _
	public DataSet SelectPaged()
	{
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[0];
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorsSelectPaged]", parameters, "XPFavoriteVedor_Paged");
	}

	//<DataObjecttMethod(DataObjectMethodType.Select)> _
	public SqlDataReader SelectReader(int FavorID)
	{
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("FavorID", FavorID) };
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorSelect]", parameters);
	}

	//<DataObjecttMethod(DataObjectMethodType.Select)> _
	public SqlDataReader SelectReaderByCompanyID(Guid CompanyID)
	{
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("CompanyID", CompanyID) };
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorsSelectByCompanyID]", parameters);
	}

	//<DataObjecttMethod(DataObjectMethodType.Select)> _
	public SqlDataReader SelectReaderByVendorID(Guid VendorID)
	{
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("VendorID", VendorID) };
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorsSelectByVendorID]", parameters);
	}

	//<DataObjecttMethod(DataObjectMethodType.Select)> _
	public DataSet SelectSingle(int FavorID)
	{
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("FavorID", FavorID) };
		DataSet ds = dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorSelect]", parameters, "XPFavoriteVedor_Single");
		DataTable dt = ds.Tables["XPFavoriteVedor_Single"];
		return ds;
	}

	//<DataObjecttMethod(DataObjectMethodType.Update)> _
    public int Update(XPFavoriteVedorInfo info)
	{
		int RowsAffected = 0;
		DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
		SqlParameter[] parameters = new SqlParameter[] {
			new SqlParameter("FavorID", info.FavorID),
			new SqlParameter("CompanyID", info.CompanyID),
			new SqlParameter("VendorID", info.VendorID),
			new SqlParameter("FolderID", info.FolderID),
			new SqlParameter("CreateDate", info.CreateDate),
			new SqlParameter("LastSaveDate", info.LastSaveDate),
			new SqlParameter("DeleteDate", info.DeleteDate),
			new SqlParameter("Comment", info.Comment)
		};
		return dbo.RunProcedure("[dbo].[xunpan_XPFavoriteVedorUpdate]", parameters, RowsAffected);
	}

}



}
